#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/5/6 11:22 上午
# @Author  : adam
import pymongo
from bson import json_util
import json

myclient = pymongo.MongoClient("mongodb://localhost:27017/")

# dblist = myclient.list_database_names()

mydb = myclient.test
collist = mydb.list_collection_names()


# class JSONEncoder(json.JSONEncoder):
#     def default(self, o):
#         if isinstance(o, ObjectId):
#             return str(o)
#         return json.JSONEncoder.default(self, o)


my_set = mydb.saas_357
count_a=my_set.count()

# all_info = my_set.find({}, {"_id": 0})
all_info = my_set.find({}).limit(100).skip(0)

# mm=json_util.dumps(all_info)
# # mm=json.JSONEncoder().encode(all_info)
# print(mm)
#
# kk=json.loads(mm)
# print(kk)
# # sss = json.dumps(all_info, sort_keys=True, indent=4, default=json_util.default)
#
for i in all_info:
    print(i)
#
# one_onfo = my_set.find_one()
# print(one_onfo)
